package com.事件处理event.Google恐龙;

import java.util.Vector;

public class Barrier extends Thread {
    static Vector<Barrier> vector = new Vector<>();
    int x, y;
    boolean isLive = true;

    public Barrier(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public void run() {
        while (x >= -50 && isLive) {
            x--;
            Recorder.Step_count++;
            try {
                sleep(1);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        try {
            sleep((int) (Math.random() * 2));
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        if (isLive) {
            Recorder.num++;
            Barrier b1 = new Barrier(1605, 623 - 15);
            b1.start();
            vector.add(b1);
        }
        vector.remove(this);
    }
}
